  FastImage ( 1.7x)  3 ( 1.98-1.105, SDK 1.05)


	 : http://www.fastlibs.com
	: http://blitz.pp.ru/forum/showthread.php?s=&threadid=1497
	(c) 2006-2010    MixailV aka Monster^Sage [monster-sage@mail.ru]


        2   3
(  1.98  ,       )
         ,
   ,   2  .
    ,   
     .
     7     ,   
 ,        ,  
    .

 ,   ,    ,   
   LoadImageEx  CreateImageEx    . , 
      (-  --), 
    ,   ,  
22, 44, 88, 1616, 3232, 6464, 128128, 256256, 512512, 10241024, 20482048.
   ,   ,     
 "",     ,  "" .
      ,     .
 ()    ,  ,  DDS.


 :
 - Dmitry 'ABTOMAT' Maslov          
 - L.D.M.T.      




*  :


InitDraw% ()
	      .
	     Graphics3D.
	  0,     .
	

DeinitDraw% ()
	        ,
	     ,   2 
	       .   
	      EndGraphics.
	    ,    
	   .
	     ,     EndGraphics
	     ,   ,  
	  .


StartDraw% ()
	      
	 (, ,   ..)
	  ,    
	      - .
	        .
	      ,    .
	      ,    
		Cls
		StartDraw
			;    2
		EndDraw
		CameraClsMode camera, 0, 1
	 ,     (    
	       7),    .
		

EndDraw% ()
	         
	 StartDraw.


DrawVersion$()
	        X.YY  X.YY.Z




*   :


SetDefault% ( [all%=1] )
	      .
	( ,      InitDraw ,
	  AutoMidHandleEx and AutoImageFlags).
	 ,      .
	   all%   ,   2D    .


SetBlend% (blend%)
	      ,     .
	      FI_ALPHABLEND.
	   ():
	
		FI_SOLIDBLEND = 0
			       
			
		FI_ALPHABLEND = 1
			      ( SetAlpha)
			           -,
			     .
			
		FI_LIGHTBLEND = 2
			    ,   ALPHABLEND, 
			 .    .
			
		FI_SHADEBLEND = 3
			    ,   ALPHABLEND, 
			      ,     .
			   -    .
			
		FI_MASKBLEND = 4
			    "",    ,   
			0.5  ,  .  ,    
			 SetAlpha   0.5   0.5,     .
			
		FI_MASKBLEND2 = 5
			 MASKBLEND,     -   .
			
		FI_INVALPHABLEND = 6
			 ALPHABLEND,     ,   ALPHABLEND .
			 -    "".

		
SetCustomBlend% (src%, dest%)
	     .  src  dest  
	   1  10,          7.
	        ,  
	  7. .  FastImage_Example_CustomBlends.bb

	
SetAlpha% (alpha#)
	     .    
	 0.0 ()  1.0 ( ).    .
	    (Blend),  SOLIDBLEND.
	      1.0
	

SetColor% (r%, g%, b%)
	   ,   : , , ,
	   0  255.        (255, 255, 255)

	
SetCustomColor% (ColorVertex0%, ColorVertex1%, ColorVertex2%, ColorVertex3%)
	       $AARRGGBB
		  (4-)  -  ($00- , $FF- )
		3-  -  
		2-  -  
		 (1-)  -  
	 ColorVertex0  ,    SetColor.
	  ,   .
	        .
	   1.0 -     ,    
	  .     , 
	        
	 .


SetRotation% (Rotation#)
	     .    ,   .
	    ,      ,  
	   Simple (DrawLineSimple, DrawRectSimple)


SetScale% (scaleX#, scaleY#)
	        X  Y,   
	  .   , 1.0 -   
	(2.0 -       ..)
	       Simple (DrawLineSimple, DrawRectSimple)


SetTransform% (rotation#, scaleX#, scaleY#)
	      ,    .
	  .  SetRotation  SetScale.
	       Simple (DrawLineSimple, DrawRectSimple)


SetMatrix% (xx#, xy#, yx#, yy#)
	  2    (22).  
	,    .
	       Simple (DrawLineSimple, DrawRectSimple)


SetOrigin% (x#, y#)
	     ,     .
	    Plot,   ,      .
	       Simple (DrawLineSimple, DrawRectSimple)


SetHandle% (x#, y#)
	    ,    .
	   ,   DrawRect, DrawLine, DrawOval


SetLineWidth% (width#)
	    ( ),    
	 DrawLine  DrawLineSimple.


SetViewport% (x%, y%, width%, height%)
	   (),       .
	,        ,     
	,        ()
	  ,       ( ).
	   .


SetMipLevel% (level%)
	  .
	  MipMap   ,    .
	  ,       8 ( ).
	 DDS        .  
	         
	  256  8,          
	   .     ,   
	  ,    .


SetCustomState% (operation%, value%)
	   .
	  SetRenderState(operation%, value%)  7.


SetCustomTextureState% (operation%, value%)
	   .
	  SetTextureStageState (0, operation%, value%)   7.
	  ,       
	  ,        
	  .
	          ,
	       :
	
		D3DTSS_ADDRESS
		D3DTSS_ADDRESSU
		D3DTSS_ADDRESSV
		D3DTSS_MIPFILTER
		D3DTSS_MINFILTER
		D3DTSS_MAGFILTER
		D3DTSS_MAXMIPLEVEL
		D3DTSS_TEXTURETRANSFORMFLAGS
		D3DTSS_COLOROP
		D3DTSS_COLORARG1
		D3DTSS_COLORARG2
		D3DTSS_ALPHAOP
		D3DTSS_ALPHAARG1
		D3DTSS_ALPHAARG2
		D3DTSS_TEXCOORDINDEX


SetCoordsRound% (mode%)
	 /      .
	mode% = 0 -   
	mode% = 1 -    (      ,
		    )
	        ,    
	   ,     .   
	    ..
	 : FastImage_Example_CoordsRound.bb


SetTint% (level#, red%, green%, blue%)
	       
	color = source_color * (1.0-level/255.0) + tint_color * level/255.0
	level# -       ,       0  255
		(0 -   , 255 - 100%  )
	red% -    ,  0  255
	green% -    ,  0  255
	blue% -    ,  0  255
	 : FastImage_Example_Tint.bb




*     :


CreateImageEx_% (texure%, width%, height% [, imageFlags% = FI_AUTOFLAGS] )
	   ()  .      
	 (    ),      
	 LoadTexture  LoadAnimTexture.  ,  ,     
	 ()       2 .
	!       256  8,    
	 ,        .
	  ()       
	 2 , .   :
	
		FI_AUTOFLAGS = -1
			,   .   ,    , 
			  AutoImageFlags.
			
		FI_NONE = 0
			 ,     .
		
		FI_MIDHANDLE = 1
			,       
			(   - ImageHandle).   ,   
			   AutoMidHandleEx
		
		FI_FILTEREDIMAGE = 2
			,  ,       ,   
			    (, ).

		 FI_MIDHANDLE  FI_FILTEREDIMAGE      "Or".
		
	  (),      2 .  
	   .     ,    
	  ( ).


LoadImageEx% (fileName$, textureFlags%, imageFlags%)
	    .     ,
	         .  
	  ,      .
	   :
		fileName$ -   
		textureFlags% -   ,        LoadTexture  LoadAnimTexture
		imageFlags% -   ,        CreateImageEx.
	  (),      2 .  
	   .     ,    
	  ( ).
	        FastImage_Example_TestObjects.bb
		

LoadAnimImageEx% (fileName$, textureFlags%, frameWidth%, frameHeight%, firstFrame%, frameCount%, imageFlags%)
	     .     ,
	         .
	   :
		fileName$ -   
		textureFlags% -   ,        LoadTexture  LoadAnimTexture
		frameWidth% -  
		frameHeight% -  
		firstFrame% -   
		frameCount% -  
		imageFlags% -   ,        CreateImageEx.
	  (),      2 .  
	   .     ,    
	  ( ).
	        FastImage_Example_Animation.bb


SetImageHandle% (image%, x#, y#)
	      .
	

AutoImageFlags% (flags%)
	  -,       ( 
	  ,   FI_AUTOFLAGS).
	     = FI_MIDHANDLE + FI_FILTEREDIMAGE
	
	
MidHandleImage% (image%)
	      (    ).
	

AutoMidHandleEx% (state%)
	    .   1,   ,  
	  CreateImageEx     .
	     ( ).

	
FreeImageEx% (image%, freeTexture%=0)
	   .
	  freeTexture  ,         .
	!    ,   ,     ,
	          .
	           .
	 ,    ,    .


CountImages% ()
	    ,   .


GetImageByIndex% (ImageIndex%)
	     .  ImageIndex%     
	    .  :
		For i=0 To CountImages()-1
			image = GetImageByIndex(i)
		Next


UpdateImage% (image%, texture% [, width%=0, height%=0] )
	     texture%  image%.
	   width%  height%  ,      .


UpdateImageFlag% (image% [, update%=-1] )
	     updateFlag%   image%.  
	         update%.
	  updateFlag%       ImagesIsLost,
	           
	(           Alt-Tab)
	    (  Win+L).
	     ,     ,
	   (  CreateTexture   256   ),
	         .


DrawImageEx% (image%, x#, y# [, frame% = 0] )
	        c   
	  .        ,
	      -  . .      .
	 ,    ,    .


DrawImageRectEx% (image%, x#, y#, width#, height# [, frame% = 0] )
	        c    ,
	        .     
	  ,       -  . .
	     .
	 ,    ,    .


DrawImagePart% (image%, x#, y#, width#, height# [, partX#=0, partY#=0, partWidth#=0, partHeight#=0, frame%=0, wrap%=FI_NOWRAP] )
	       X  Y.
	Width  Height -        
	partX  partY -       
	partWidth  partHeight -       ( ,     )
	wrap -   ,      .
	  Wrap:
		FI_NOWRAP = 0 -   
		FI_WRAPU = 1 -     X
		FI_MIRRORU = 2 -     X
		FI_WRAPV = 4 -     Y
		FI_MORRORV = 8 -     Y
		FI_WRAPUV = 5 -    
		FI_MIRRORUV = 10 -    
		 FI_WRAPU, FI_MIRRORU, FI_WRAPV, FI_MIRRORV    OR
	   FastImage_Example_DrawImagePart.bb


DrawRect% (x#, y#, width#, height# [, fill% = 1] )
	         ,
	        .   
	.    fill = 0,     .


DrawRectSimple% (x#, y#, width#, height# [, fill% = 1] )
	         ,
	      ,   .
	       
	   GUI  HUD.    .
	   fill = 0,     .


DrawLine% (x#, y#, x2#, y2#)
	    x,y   x2,y2
	     ,    .

	
DrawLineSimple% (x#, y#, x2#, y2#)
	    x,y   x2,y2
	        .    .
	           GUI  HUD.


DrawPlot% (x#, y#)
	        (,   ..)


DrawOval% (x#, y#, width#, height#)
	           ,
	        .


DrawPoly% (x#, y#, bank%, image%=0, frame%=0, color%=FI_NONE)
	      X  Y.
	bank -  ,        (. )
	image -   ,      
	frame -        (       )
	color -    ,    SetAlpha  SetColor (     )
	  Color: FI_NONE  FI_COLOROVERLAY
		
	   ,     :
		c  -  

		+0  -    (  - integer)

		+4  -  Wrap (.     DrawImagePart)

		+8  -   ,   :
			FI_POINTLIST     = 1 -  
			FI_LINELIST      = 2 -   ()
			FI_LINESTRIP     = 3 -   ( )
			FI_TRIANGLELIST  = 4 -  ,     
			FI_TRIANGLESTRIP = 5 -   (  )
			FI_TRIANGLEFAN   = 6 -   (    )

		+12 - _   FI_TRIANGLELIST_ =    

		+16 - _   FI_TRIANGLELIST_ =      

		+20 -     ,     20      :
			(N = 1 ... 16384 -   )
			20*N + 0  -  X  (  - float)
			20*N + 4  -  Y  (  - float)
			20*N + 8  -       $AARRGGBB (  - integer)
			20*N + 12 - U - X    (  - float)
			20*N + 16 - V - Y    (  - float)

	           ,
	      .
	   FastImage_Example_DrawPoly.bb, FastImage_Example_DrawPoly2.bb


DrawPolyEx% (x#, y#, bank%, image%=0, frame%=0, color%=FI_NONE)
	      X  Y.
	bank -  ,        (. )
	image -   ,      
	frame -        (       )
	color -    ,    SetAlpha  SetColor (     )
	  Color: FI_NONE  FI_COLOROVERLAY
		
	   ,     :
		c  -  

		+0  -    (  - integer)

		+4  -  Wrap (.     DrawImagePart)

		+8  -   ,   :
			FI_POINTLIST     = 1 -  
			FI_LINELIST      = 2 -   ()
			FI_LINESTRIP     = 3 -   ( )
			FI_TRIANGLELIST  = 4 -  ,     
			FI_TRIANGLESTRIP = 5 -   (  )
			FI_TRIANGLEFAN   = 6 -   (    )

		+12 - _   FI_TRIANGLELIST_ =    

		+16 - _   FI_TRIANGLELIST_ =      

		+20 -     ,     24      :
			(N = 1 ... 16384 -   )
			24*N + 0  -  X  (  - float)
			24*N + 4  -  Y  (  - float)
			24*N + 8  -       $AARRGGBB (  - integer)
			24*N + 12 - U - X    (  - float)
			24*N + 16 - V - Y    (  - float)
			24*N + 20 - W (RHW)    (  - float, 1.0 -   )

	           ,
	      .


DrawRoundRect (x#, y#, w#, h#, RoundRectRadius%=40, RoundRectCorners%=-1, Color%=$FFFFFFFF, Image%=0 )
	     .    StartDraw  EndDraw,
	..    FastImage        .
	:

		x,y -      ( )
		w,h -      ( )

		RoundRectRadius% -    ( )

		RoundRectCorners% -    .    -   ,
		       .     -1,  
		    .    -1

		Color% -     .    $AARRGGBB.   
		  ARGB(A#,R,G,B) (       )  ,   
		   A#,R,G,B.   Color%  $FFFFFFFF, ..    .
		
		Image% -   ,   0     .

		  FastImage_Example_RoundRect.bb.
			[       aka ABTOMAT ]

								


*     :


ImagesIsLost%()
	  ,       Alt+Tab (  )
	     Win+L (  )      
	().      (   ) 
	  .        -    ,
	         ,    
	   .

	     ,      ,  
	    ,         
	 .           .

	  ,          
	(     -    ),    :

		1.      ImagesIsLost(),     ,  . 2 

		2.    ,       ,  Cls  Flip,
		   +     ,      ,
		        ImagesIsLost().    ,     3.
		        -  ( 2-5 , 
		       ,    ).

		3.   :            
		     ,     ,     
		      .


GetProperty% ()
	      ,    .
	  . .  :
	
		GetProperty
		LibraryBlend	= FI_Property\Blend
		LibraryAlpha	= FI_Property\Alpha
		LibraryRed	= FI_Property\Red
		LibraryGreen	= FI_Property\Green
		 ..
		
	   :

		Blend%
		Alpha#, Red%, Green%, Blue%
		ColorVertex0%, ColorVertex1%, ColorVertex2%, ColorVertex3%                                 	
		Rotation#, ScaleX#, ScaleY#
		MatrixXX#, MatrixXY#, MatrixYX#, MatrixYY#
		HandleX#, HandleY#
		OriginX#, OriginY#
		AutoHandle%, AutoFlags%
		LineWidth#
		ViewportX%, ViewportY%, ViewportWidth%, ViewportHeight%
		MipLevel%
		ProjScaleX#, ProjScaleY#, ProjRotation#
		ProjOriginX#, ProjOriginY#
		ProjHandleX#, ProjHandleY#
		CoordsRound%
		TintLevel#, TintColorRed%, TintColorGreen%, TintColorBlue%


	   FastImage_Example_All.bb
	 (  )   .


GetImageProperty% (image%)
	          ,
	   .
	  . .  :
	
		GetImageProperty image
		ImageWidth  = FI_ImageProperty\Width
		ImageHeight = FI_ImageProperty\Height
		ImageFrames = FI_ImageProperty\Frames
		 ..
		
	    :

		HandleX#
		HandleY#
		Width%
		Height%
		Frames%
		Flags%
		Texture%
		TextureWidth%
		TextureHeight%
		TextureFlags%
		TextureFrames%
		TextureUpdate%

	 (  )   .




*   :


SetProjScale% (scaleX#, scaleY#)
	   2 , 1.0  .    
	  ""   -,    
	  ,       .
	    .
	:     - 1024768 ,   
	     800600.     , 
	scale# = 800.0 / 1024.0,    SetProjScale scale#, scale#
	,          
	     !


SetProjRotation% (rotation#)
	  2     ( ).   
	,    SetProjHandle  MidHandleProj.   
	   x=0, y=0  2  (  ).
	    .
	,          
	     !


SetProjTransform% (rotation#, scaleX#, scaleY#)
	      .   
	   SetProjRotation  SetProjScale.


SetProjOrigin% (x#, y#)
	   2    X  Y.      .
	    .

SetProjHandle% (x#, y#)
	    2 ,    
	 (ProjOrigin)   (ProjRotation) .   
	   x=0, y=0  2  (  ).


MidHandleProj% ()
	     2 ,     
	 ,      Graphics3D,
	       (ProjOrigin)
	  (ProjRotation) .      
	x=0, y=0  2  (  ).




*     -:

LoadImageFont% (filename$, flags%=FI_SMOOTHFONT)
	 -      .   
	   ( ),    FI_SMOOTHFONT,   ,
	   .      :

		; 

		AnimTexture = Font.png	-    
		AnimTextureFlags = 2	-   
		FrameWidth = 32		-    
		FrameHeight = 32	-    
		FrameCount = 256	-    

		; 		

		Width = 32		-    (,         )
		Height = 32		-   
		FirstChar = 0		-     -
		Kerning = 0		-   
		FrameX = 0		-       X
		FrameY = 0		-       Y

		32 = 14			-     32 ()
		33 = 7			-     33  ..
		34 = 10
		35 = 16
		36 = 14
		...

	   0,            
	  .


FreeImageFont% (font%)
	 ,  . ,     ,   !


SetImageFont% (font% [, customKerning%] )
	 ,     .   
	  .
	  customKerning%       .
	   ,    ,      .
	 : FastImage_Example_TextAndFont_Kerning.bb 


DrawText% (text$, x#, y#, centerX%=0, centerY%=0, maxWidth%=10000)
	      X  Y.    
	  .  maxWidth%        - .  	


DrawTextRect% (txt$, x#, y#, width#, height#, centerX%=0, centerY%=0, lineSpacing%=0)
	   ,  
	  x%  y%  ,    width  height.
	     :
		centerX = 0	-    (  )
		centerX = 1	-  
		centerX = 2	-   
		centerX = 4 	-          , 
				      centerX   4.
		centerX = 8	-     ,     
				   (.    )
	     :
		centerY = 0	-    (  )
		centerY = 1	-  
		centerY = 2	-   
	        lineSpacing.
	     ,      (   ).


TextRectCount%()
	         DrawTextRect


TextRectMaxWidth%()
	         DrawTextRect


TextRectWidth% (StringNumber%)
	         DrawTextRect.
	     StringNumber%.        - ,
	     .


StringWidthEx% (text$, maxWidth%=10000)
	           maxWidth%.
	 maxWidth%        - .  	


StringHeightEx% (text$)
	       .


GetFontProperty% (font%)
	   ,  .
	 :
		GetFontProperty MyFont
		MyFontWidth		= FI_FontProperty\Width			-  
		MyFontHeight		= FI_FontProperty\Height		-  
		MyFontFirstChar		= FI_FontProperty\FirstChar		-     
		MyFontImage		= FI_FontProperty\Image			-  
		MyFontFrameWidth	= FI_FontProperty\FrameWidth		-    
		MyFontFrameHeight	= FI_FontProperty\FrameHeight		-    
		MyFontFrameCount	= FI_FontProperty\FrameCount		- -  ( )  
		MyFontFrameX		= FI_FontProperty\FrameX		-       X
		MyFontFrameY		= FI_FontProperty\FrameY		-       Y
		MyFontKerning		= FI_FontProperty\Kerning		-   ,     
		MyFontKerningCustom	= FI_FontProperty\KerningCustom		-   ,    
		MyFontChar		= FI_FontProperty\Chars[char_code%]	-      0  255




*      :


TestRect% (xPoint#, yPoint#, xRect#, yRect#, WidthRect#, HeightRect#, Local%)
	     xPoint#, yPoint#  ,
	   xRect#, yRect#    WidthRect#
	  HeightRect#.  Local%  (  1 ),  
	     ,    .

	   ,  : SetRotation,
	SetScale, SetTransform, SetOrigin, SetHandle.    
	     ( Local%=0 ),  
	  ,   SetProjRotation,
	Set ProjScale, SetProjTransform, SetProjOrigin, SetProjHandle, MidHandleProj.

	   1,     ,
	    .

	   ,  ,  
	   FI_Test  :
		result		= FI_Test\Result	-   
		projectedX 	= FI_Test\ProjectedX	- X     (  )
		projectedY 	= FI_Test\ProjectedY	- Y     (  )
		rectX 		= FI_Test\RectX		- X      
		rectY		= FI_Test\RectY		- Y      
		rectU		= FI_Test\RectU		- U      ,  RectX,  RectX   Width 
		rectV		= FI_Test\RectV		- U      ,  RectY,  RectY   Height 
		textureX	= FI_Test\TextureX	- X    ,  RectU *   (     ,   )
		textureY	= FI_Test\TextureY	- Y    ,  RectV *   (     ,   )
		texture		= FI_Test\Texture	-  ,     (     ,   )

	    FastImage_Example_TestObjects.bb


TestOval% (xPoint#, yPoint#, xOval#, yOval#, WidthOval#, HeightOval#, Local%)
	     xPoint#, yPoint#   (),
	   xOval#, yOval#    WidthOval#
	  HeightOval#.  Local%  (  1 ),  
	     ,    .

	        TestRect.
	    FastImage_Example_TestObjects.bb


TestImage% (xPoint#, yPoint#, xImage#, yImage#, Image%, alphaLevel%, Frame%, Local%)
	     xPoint#, yPoint#   Image%,
	   xImage#, yImage#.  alphaLevel% 
	     ,     0  255.
	  alphaLevel%        .
	    ( alphaLevel% >0 )   
	,        .  Local%
	 (  1 ),        ,
	   .

	   ,  : SetRotation,
	SetScale, SetTransform, SetOrigin, SetHandle.    
	     ( Local%=0 ),  
	  ,   SetProjRotation,
	SetProjScale, SetProjTransform, SetProjOrigin, SetProjHandle, MidHandleProj.

	   1,     ,
	    .    alphaLevel%,  
	       .

	   ,  ,  
	   FI_Test,    (  TestRect).

	    FastImage_Example_TestObjects.bb


TestRendered% (xPoint#, yPoint#, alphaLevel%, Local%)
	     xPoint#, yPoint#  , 
	     .

	!       :
		DrawImageEx, DrawImageRectEx, DrawImagePart, DrawRect, DrawRectSimple, DrawOval.

	 alphaLevel%        ,
	    0  255.   alphaLevel%    
	   .     ( alphaLevel% >0 )
	   ,        .
	 Local%  (  1 ),       
	,    .

	      ,  :
	SetRotation, SetScale, SetTransform, SetOrigin, SetHandle.    
	     ( Local%=0 ),  
	  ,   SetProjRotation,
	SetProjScale, SetProjTransform, SetProjOrigin, SetProjHandle, MidHandleProj.

	   1,      ,
	    .    alphaLevel%,  
	       .

	   ,  ,  
	   FI_Test,    (  TestRect).

	    FastImage_Example_TestObjects.bb


